<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored ="false"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String userInfoDtosJson = (String)request.getAttribute("userInfoDtosJson");
	String saveType = "detail";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>北京市电子行政监察平台-报送发起</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link href="<%=path%>/css/base.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/frame.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/jQueryTree-1.2.1.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
			var path = "<%=path%>";
		</script>
		<%@ include file="../../test/getExcelFormat.jsp" %>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery-1.4.3.pack.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/util.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/oacore.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/multi_upload.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/init.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery.metadata.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery.validate.fixed.pack.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/jQueryTree-1.2.1.min.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/AccountBook2.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/excelformatjs/commons.js"></script>
		<script type="text/javascript">
			$(function () {
					//上报人 
					var accountBookJsonStr1 = "<%=userInfoDtosJson%>";		
					new AccountBook({
							input: $(".use-account-book"),
							mode: "checkbox",
							defaultValue: [],
							data: $.parseJSON(accountBookJsonStr1),
							pretreatment: function (data) {
								data.id = data.userInfoId;
								delete data.userInfoId;
								data.content = data.userName;
								delete data.userName;
								return data;
							}
						});

					//审批人 
					var accountBookJsonStr2 = "<%=userInfoDtosJson%>";		
					new AccountBook({
							input: $(".use-accountbook"),
							mode: "single",
							defaultValue: [],
							data: $.parseJSON(accountBookJsonStr2),
							pretreatment: function (data) {
								data.id = data.userInfoId;
								delete data.userInfoId;
								data.content = data.userName;
								delete data.userName;
								return data;
							}
						});
					


					//初始化表单值校验器
					$("#creatorForm").validate();
					//初始化报送方式选择器
					$(".report-method[checked!='']:first").trigger("click");
					
					//初始化时间选择器
					$("input.use-datepicker").bind("focus", function () {
							WdatePicker({
									dateFmt: "yyyy-MM-dd",
									minDate: "%y-%M-{%d}"
								});
						});
					$("input.datepicker-low").bind("focus", function () {
						var dpHigh=$dp.$("dpMax");
						WdatePicker(
							{
								dateFmt: "yyyy-MM-dd",
								minDate: "%y-%M-{%d}",
								maxDate: "#F{$dp.$D(\'dpMax\')}"
							}
						);
					});
					$("input.datepicker-high").bind("focus", function () {
						var dpMax=$dp.$("dpMax");
						var dpLow=$dp.$("dpLow");
						//#F{$dp.$D(\'dpLow\')}
						WdatePicker(
							{
								dateFmt: "yyyy-MM-dd",
								minDate: "#F{$dp.$D(\'dpLow\')}",
								maxDate: "#F{$dp.$D(\'dpMax\')}"
							}
						);
					});

				
					//初始化去向选择器
					$("input.nextstep-option").bind("click", function () {
							var $this = $(this);
							if($this.hasClass("nextstep-option-submit"))
								$("tr.nextstep-submit").show();
							else if($this.hasClass("nextstep-option-promotion"))
								$("tr.nextstep-submit").hide();
						}).filter(":checked").trigger("click");
					//初始化上报方式选择器
					$("input.report-method-selector").bind("click", function () {
							var $this = $(this);
							if($this.hasClass("report-method-attachment"))
								$("#templateSelector").hide();
							else if($this.hasClass("report-method-onlineform"))
								$("#templateSelector").show();
						}).filter(":checked").trigger("click");
					//触发选择
					new oacore.Widget.MultiUpload({
						fileList: $("#uploadFileList"),
						trigger: $("#uploadFileTrigger"),
						descriptionName: "description",
						fileName: "files"
					});	

					$("#showExcel").hide();
					$("#isExcel").click(function(){
						$("#showExcel").show();
					});
					$("#isForm").click(function(){
						$("#showExcel").hide();
					});
					$("#isAtt").click(function(){
						$("#showExcel").hide();
					});
				});
			
		</script>
		
		<script type="text/javascript">
			//$(function(){
			//	alert("请编辑上报表单格式，并指定可编辑区域！");
			//});
			
			//是否选中可编辑区域标识
			var flg = false;
			
			//选中的可编辑区域首行号 
			var data_row = 0;//需求指定数据来自一行，所以该行即为数据行 

			//保护工作表
			function protectSheet(){
				if(confirm("你确认已经选中了可编辑区域?")){
					//选中该sheet
					webform.WebOffice.WebObject.Application.Sheets(1).Select;
					//为选中行号赋值 
				   	data_row = webform.WebOffice.WebObject.Application.Selection.row;
				   	//为选中区域位置赋值  
				   	//data_address = webform.WebOffice.WebObject.Application.Selection.address;
				   	
				   	$("#dataRow").val(data_row - 1);
				   	//解锁选中行
				    webform.WebOffice.WebObject.Application.Selection.Locked = false;
				    webform.WebOffice.WebObject.Application.Selection.FormulaHidden = false;
				    //锁定该sheet 
				    webform.WebOffice.WebObject.Application.ActiveSheet.Protect(true,true,true);
				    alert("已经保护了工作表，设定您选中的单元格为可修改区域。");
				    flg = true;
				} 
			}
			function validateSaveDocument(){
				if($("#isExcel").attr("checked")==true){
					if(flg==false){
						alert("请您务必先指定可编辑区域，以便上报工作正常进行。");
						return false;
					}
					SaveDocument();
					return true;
				}
				return false;
			}
		</script>
		<style type="text/css">
			
		</style>
		<style type="text/css">
			div {
				position: static;
			}
		</style>
	</head>
	<body>
		<div id="mainPage" class="surround-layout">
			<jsp:include page="../../frame/top.jsp" flush="true"></jsp:include>
			<div class="middle">
				<jsp:include page="../../frame/middle_left.jsp" flush="true">
					<jsp:param value="1019-1020" name="view"/>
				</jsp:include>
				<!-- 右侧输出内容 -->
				<div class="right">
					<div class="right-all-content">
						<div>
							<div class="content-line-wrap">
								<div class="content-line-left content-line">
									<h1 class="content-title">
										<span>
											<a href="launchReportAction.action?parame=sbfq">报送发起</a>
										</span>
									</h1>
								</div>
							</div>
							<div class="inner-dialog">
								<h1 class="inner-dialog-title">
									报送发起
								</h1>
								<div class="inner-dialog-content">
									<form method="post" action="<%=path%>/web/startReportAction.action" name="webform" id="creatorForm" enctype="multipart/form-data" class="normal-form" onsubmit="return validateSaveDocument();">
										<h1 class="inner-form-title">报送任务信息</h1>
										<table class="data-view-table tiny-form-table" cellspacing="0">
											<tbody>
												<tr class="odd">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														报送任务名称:
													</td>
													<td colspan="3" class="dvt-value">
														<input type="text" name="missionDto.missionName" value="${missionDto.missionName}" class="shadow tft-textinput {required: true, dataName: true, maxlength: 32, messages: {required: '任务名称项为必填', maxlength: '任务名称项的长度不能超过32个字符', dataName: '任务名称的格式须为中英文、数字及下划线'}}"/>
													</td>
												</tr>
												<tr class="even two-field">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														来源:
													</td>
													<td class="dvt-value">
														<select name="missionDto.importanceDTO.dataValueId" class="tft-select required {required: true, messages: {required: '重要程度项为必选'}}">
															<s:if test="importanceList">
																<s:iterator id="importance" value="importanceList">
																    <s:if test="#importance.value=='普通'">
																    <option value="${importance.dataValueId }" selected="selected">${importance.value}</option>
																    </s:if>
																    <s:else>
                                                                     <option value="${importance.dataValueId }">${importance.value}</option>    
																    </s:else>
																</s:iterator>
															</s:if>
														</select>
													</td>
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														任务计划结束日期:
													</td>
													<td class="dvt-value">
														<input id="dpMax" type="text" name="missionDto.scheduleEndDate" value="${missionDto.scheduleEndDate }" class="shadow tft-textinput use-datepicker {required: true, messages: {required: '任务计划结束日期项为必选'}}"/>
													</td>
												</tr>
												<tr class="odd">
													<td class="dvt-filed">
														任务描述:
													</td>
													<td colspan="3" class="dvt-value">
														<textarea class="shadow tft-textarea {maxlength: 64, messages: {maxlength: '任务描述不能超过64个字符'}}" name="missionDto.description" ><s:property value="missionDto.description"/></textarea>
													</td>
												</tr>
											</tbody>
										</table>
										<h1 class="inner-form-title">报送要求</h1>
										<table class="data-view-table tiny-form-table" cellspacing="0">
											<tbody>
												<tr class="odd two-field">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														报送开始日期:
													</td>
													<td class="dvt-value">
														<input type="text" id="dpLow" name="launchReportJobDto.reportStartDate" class="shadow tft-textinput datepicker-low {required: true, lteDate: '#dpMax', messages: {required: '报送开始日期项为必选', lteDate: '报送开始日期不得大于任务结束日期'}}"/>
													</td>
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														报送结束日期:
													</td>
													<td class="dvt-value">
														<input type="text" id="dpHigh" name="launchReportJobDto.reportEndDate" class="shadow tft-textinput datepicker-high {required: true, gteDate: '#dpLow', lteDate: '#dpMax', messages: {required: '报送结束日期项为必选', gteDate: '报送结束日期不得小于报送开始日期', lteDate: '报送结束日期不得大于任务开始日期'}}"/>
													</td>
												</tr>
												<tr class="even">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														报送人:
													</td>
													<td class="dvt-value" colspan="3">
														<input type="text" name="userInfoIds" class="shadow tft-textinput use-account-book {required: true, messages: {required: '报送人项为必选'}}"/>
														<div style="margin-top: 4px;color: #666666;">
															说明：请选择本次需要进行报送机构或个人，若选择机构，任务将发送至该机构下所有人。
														</div>
													</td>
												</tr>
												<tr class="odd">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														报送类型:
													</td>
													<td class="dvt-value" colspan="3">
														<div style="height: 24px;">
															<label class="odd" style="float: left;">
																<input id="isAtt" type="radio" name="launchReportJobDto.reportMethod" value="F" checked="checked" class="report-method-selector report-method-attachment {required: true, messages: {required: '报送方式项为必选'}}" />信息文字
															</label>
															<label class="even" style="float: left;margin-left: 8px;margin-right: 8px;">
																<input id="isForm" type="radio" name="launchReportJobDto.reportMethod" value="B" class="report-method-selector report-method-onlineform {required: true, messages: {required: '报送方式项为必选'}}"/>数据材料
															</label>
															<span id="templateSelector" style="display: none;">
																<s:select name="launchReportJobDto.flowFormDto.formId" list="flowFormDtos" listKey="formId" cssClass="inputform-select _hide {showedRequired: true, messages: {showedRequired: '请选择一个电子表单模板'}}" listValue="formName" value="formId" headerKey="" headerValue="请选择电子表单模板" theme="simple" ></s:select> 
															</span>
															<label>
																<input type="radio" id="isExcel" name="launchReportJobDto.reportMethod" value="E" class="report-method-selector report-method-attachment {required: true, messages: {required: '报送方式项为必选'}}" />自定义excel表格
															</label>
																
															<div id="showExcel" style="height: 540px;">
																<input type="hidden" value="" name="onlinePath" id="path" />
																<input type="hidden" value="" name="onlineVersion" id="documentVersion"/>
																<input type="hidden" name="dataRow" id="dataRow"/>
																<script src="<%=path%>/javascript/excelformatjs/iWebOffice2009.js"></script>
																<input type="button" onclick="protectSheet();" value = "设置表格的可填写区域">
															</div>
														</div>
														<div style="margin-top: 4px;color: #666666;clear: both;">
															说明：信息文字类内容以附件形式报送，数据材料类内容以在线表单形式报送。
														</div>
													</td>
												</tr>
												<tr class="even">
													<td class="dvt-filed">
														报送要求:
													</td>
													<td colspan="3" class="dvt-value">
														<textarea name="launchReportJobDto.reportRequirement"  class="shadow tft-textarea {maxlength: 64, messages: {maxlength: '报送要求项的长度不能超过64个字符'}}"></textarea>
													</td>
												</tr>
												<tr class="odd">
													<td class="dvt-filed">
														添加附件:
													</td>
													<td colspan="3" class="dvt-value">
														<ul class="file-list" id="uploadFileList">
														</ul>
														<button id="uploadFileTrigger">上传文件</button>
													</td>
												</tr>
											</tbody>
										</table>
										<table class="data-view-table tiny-form-table" cellspacing="0">
											<tbody>
												<tr class="odd">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														下一步去向:
													</td>
													<td class="dvt-value">
														<label class="tft-radiolabel odd">
															<input type="radio" name="launchReportJobDto.reportChannel" value="submit" class="nextstep-option nextstep-option-submit" checked="checked"/> 提交审批（将上报要求交给领导审批）
														</label>
														<label class="tft-radiolabel even">
															<input type="radio" name="launchReportJobDto.reportChannel" value="sure" class="nextstep-option nextstep-option-promotion"/> 发起（直接发起此次数据上报）
														</label>
													</td>
												</tr>
												<tr class="even nextstep-submit" style="display: none;">
													<td class="dvt-filed">
														<span class="important-field-star">*</span>
														选择批示人:
													</td>
													<td class="dvt-value">
														<input type="text" name="launchReportJobDto.approval.userInfoId" class="shadow tft-textinput  use-accountbook {required: true, messages: {required: '下一审批人项为必选'}}"/>
													</td>
												</tr>
											</tbody>
										</table>
										<table>
											<tr>
												<td>
													<input type="submit" value="确定" class="special originate"></input>
												</td>
											</tr>
										</table>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!--  -->
			</div>
		</div>
	</body>
</html>